<?php
/**
 * 
 * Register page called when a user first login using GFC
 * 
 * This page should ONLY be called when user login using GFC [the 1st time]
 * 
 */
define('NOROBOT', TRUE);
define('CURSCRIPT', 'GFCregister');
require_once './include/common.inc.php';
require_once './plugins/gfc/common.php';
require_once './plugins/gfc/discuz.func.php';
if($discuz_uid) {
	showmessage('login_succeed', $indexname);
}
$profile = getGFCProfile();
if (!$profile) {
  showmessage('undefined_action');
} else {
  $gfcid = $profile['id'];
  $gfcusername = $profile['displayName'];
  //fake an email address
  $gfcemail = $gfcusername.'@googlefriendconnect.com';
  if ($_GET['regsubmit'] == "yes") {
    $username = $_REQUEST['username'];
    $email = $_REQUEST['email'];
    $formhash = $_REQUEST['formhash'];
    //register the user and login
    setcookie("gfcsyncprofile",1);
    $content = GFCRegister($profile, $username, $email, $formhash, $onlineip);
    if ($content) {
      //echo $content;
      showmessage('register_succeed', dreferer());
    } else {
      showmessage('profile_username_duplicate');
    }
  } else {
    include template('gfcregister');
  }
}
?>